package com.projectpractice.repository;

import com.projectpractice.bean.Article;
import com.projectpractice.bean.Classify;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

public interface ArticleRepository extends JpaRepository<Article, Integer> {

    public Article getArticleByAid(Integer articleId);

    @Transactional
    @Modifying
    @Query(value = "update user set acreateTime = :acreateTime, title = :title, cid = :cid, scontent = :scontent, astate = :astate where aid = :aid", nativeQuery = true)
    public void updateById(@Param("aid") Integer aid, @Param("acreateTime") String acreateTime,
                           @Param("title") String title, @Param("cid") Integer cid,
                           @Param("scontent") String scontent, @Param("astate") Integer astate);
}